package com.jdk8datedemo;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;

public class LocalDateTimeDemo {
    public static void main(String[] args) {
        //当前时间的的日历对象（包含年月日时分秒)
        LocalDateTime now = LocalDateTime.now();
        System.out.println(now);
        System.out.println(now.getYear());//年
        System.out.println(now.getMonthValue());//月
        System.out.println(now.getDayOfMonth());//日
        System.out.println(now.getHour());//时
        System.out.println(now.getMinute());//分
        System.out.println(now.getSecond());//秒
        System.out.println(now.getNano());//纳秒

        System.out.println("================");
        System.out.println(now.getDayOfYear());
        System.out.println(now.getDayOfWeek());
        System.out.println(now.getDayOfWeek().getValue());
        System.out.println(now.getMonth());
        System.out.println(now.getMonth().getValue());

        System.out.println("================");
        LocalDate localDate = now.toLocalDate();
        System.out.println(localDate);

        LocalTime localTime = now.toLocalTime();
        System.out.println(localTime);


    }
}
